package com.supermarket.manage.common.dto.stock.request;

import com.supermarket.manage.common.validation.CheckGroup;
import com.supermarket.manage.common.validation.ListIsNotBlank;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author Faxon
 * @version 1.0
 * @date 2020-03-14 19:54
 **/
@Data
@ApiModel("StockProdParams: 出入库商品 数据对象")
public class StockProdParams<T> implements Serializable {

    private static final long serialVersionUID = -8385528171273975366L;

    /**
     * 页面状态（0：新增单据，1：编辑单据）
     */
    @ApiModelProperty(value = "页面状态（0：新增单据，1：编辑单据）")
    @NotNull(message = "页面状态不能为空", groups = {CheckGroup.Add.class, CheckGroup.Get.class, CheckGroup.Update.class, CheckGroup.Delete.class})
    @Min(value = 0, message = "页面状态错误（0：新增单据，1：编辑单据）", groups = {CheckGroup.Add.class, CheckGroup.Get.class, CheckGroup.Update.class, CheckGroup.Delete.class})
    @Max(value = 1, message = "页面状态错误（0：新增单据，1：编辑单据）", groups = {CheckGroup.Add.class, CheckGroup.Get.class, CheckGroup.Update.class, CheckGroup.Delete.class})
    private Integer status;

    /**
     * 单据id
     */
    @ApiModelProperty(value = "单据id(编辑时传入)")
    private String id;

    /**
     * 用户id
     */
    @ApiModelProperty(value = "用户id（新增时传入）")
    private Long userId;


    /**
     * 商品id
     */
    @ApiModelProperty(value = "商品id")
    @NotBlank(message = "商品id不能为空", groups = {CheckGroup.Update.class, CheckGroup.Delete.class})
    private String pid;

    /**
     * 商品数量
     */
    @ApiModelProperty(value = "商品数量")
    @NotNull(message = "商品数量不能为空", groups = {CheckGroup.Update.class})
    private Integer pnumber;

    /**
     * 盘点数量
     */
    @ApiModelProperty(value = "盘点数量")
    @NotNull(message = "盘点数量不能为空", groups = {CheckGroup.Stocking.class})
    private Integer snumber;

    /**
     * 小计
     */
    @ApiModelProperty(value = "小计")
    @NotNull(message = "小计不能为空", groups = {CheckGroup.Update.class})
    private BigDecimal subtotal;


    /**
     * 商品集合
     */
    @ApiModelProperty(value = "商品集合")
    @ListIsNotBlank(message = "商品集合不能为空", groups = {CheckGroup.Add.class})
    @Valid
    private List<T> prodList;

    //---------分页条件------------

    /**
     * 页码
     */
    @ApiModelProperty(value = "页码")
    @NotNull(message = "页码不能为空", groups = {CheckGroup.Page.class})
    private Integer page;

    /**
     * 每页条目数
     */
    @ApiModelProperty(value = "每页条目数")
    @NotNull(message = "每页条目数不能为空", groups = {CheckGroup.Page.class})
    private Integer size;

    /**
     * 客户id
     */
    @ApiModelProperty(value = "客户id")
    @NotBlank(message = "客户id不能为空", groups = {CheckGroup.Page.class})
    private String buyerId;

    /**
     * 商品名称
     */
    @ApiModelProperty(value = "商品名称")
    private String pname;

    /**
     * 商品分类id
     */
    @ApiModelProperty(value = "商品分类id")
    private String cid;
}
